local TinyGameLine = {}

function TinyGameLine:new(...)
    return ClassUtils:extends(TinyGameLine, Display, ...);
end

function TinyGameLine:init(parent,name)
    self.name = name;
    self.icon = nil;
    self.tween = nil;
    self.pos = nil;
    self.length = nil;
    self.time = nil;
    self.delay = nil;
    self.rotate = nil;
    self.callback = nil;
    self:setVisible(false);
    self:loadPrefab("TinyGame/Widget/TinyGameLine", parent);
end

function TinyGameLine:onStart()
    self.icon = self:find(nil, RectTransform);
    self.gameObject.name=self.name;
end

function TinyGameLine:onShow()
    self.icon.sizeDelta=Vector2(self.icon.sizeDelta.x,0);
    self.gameObject.transform.position=self.pos;
    self.gameObject.transform.localEulerAngles=Vector3(0,0,self.rotate);
    self.tween = DOTween.To(function (t)
        self.icon.sizeDelta=Vector2(self.icon.sizeDelta.x,t);
    end, 0, self.length, self.time):SetDelay(self.delay):OnComplete(self.callback);
end

function TinyGameLine:onHide()
    if self.tween then
        self.tween:Kill();
    end
end

function TinyGameLine:drawLine(pos,length,time,delay,rotate,callback)
    self.pos = pos;
    self.length = length;
    self.time = time;
    self.delay = delay;
    self.rotate = rotate;
    self.callback = callback;
    self:setVisible(true);
end

return TinyGameLine;